<?php
	session_start();
	include('../functions/soap.php');
	include('head.php');

	if(!empty($_POST['opslaan']))
	{
		//Maak een nieuwe student aan
		$newStudent = new Student($wsdl);
		
		//Set alle InitData van het student object
		$newStudent->setData($_POST['student_nr'], $_POST['voornaam'], $_POST['achternaam'], $_POST['tussenvoegsel'], $_POST['opleiding']);
		
		$result = $newStudent->CreateStudent();
		
		//Handel het resultaat af
		if($result=="Invalid Login")
		{
			$info = '<div class="error">'.$result.'.</div>';
		}
		else
		{
			$info = '<div class="ok">De student is toegevoegd.</div>';
		}
	}

	//Kijk of er is ingelogd
	if(!isset($_SESSION['session']))
	{
		header('Location: ../');
	}
?>

<body>

    <div class="wrapper">

    	<div class="header"><img src="../img/logo.gif" /></div>
        <?php include('logininfo.php') ?>
        <div class="menu"><?php include('menu.php'); ?></div>
		<div class="sidebar">

			<?php include('../copyrightBox.php') ?>

		</div>

    	<div class="content">
    		<script type="text/javascript">
				window.addEvent('domready', function()
				{
					new FormCheck('student');
				});
			</script>
        	<h3 class="header">Student toevoegen</h3>
            <form method="post" id="student">
				<table>
					<tr>
						<td>Studentnr*:</td>
						<td><input type="text" name="student_nr" size="30" class="text-input validate['required','digit','length[7,7]']" /></td>
					</tr>
					<tr>
						<td>Voornaam*:</td>
						<td><input type="text" name="voornaam" size="30" class="validate['required']" /></td>
					</tr>
                    <tr>
						<td>Achternaam*:</td>
						<td><input type="text" name="achternaam" size="30" class="validate['required']" /></td>
					</tr>
                    <tr>
						<td>Tussenvoegsel:</td>
						<td><input type="text" name="tussenvoegsel" size="30" /></td>
					</tr>
                    <tr>
						<td>Opleiding*:</td>
                        <td>
                            <select name="opleiding" class="validate['required']">
                                <option></option>
                                <option>Informatica</option>
                                <option>Technisch Informatica</option>
                                <option>Information Engineering</option>
                                <option>Bedrijfskundige Informatica</option>
                                <option>Systeembeheer</option>
                                <option>Elektrotechniek</option>
                            </select>
						</td>
					</tr>
				</table>
				<input type="submit" name="opslaan" value="Opslaan" />
			</form>
			<?php
				if(!empty($info))
				echo($info);
			?>
            ><a href="student_overzicht.php">Terug naar overzicht</a>
        </div>

    </div>

</body>
</html>
